<!--
 * @Description:splice数组的操作方法
 * @Author: Sun
 * @Date: 2019-07-01 20:05:50
 * @LastEditors: Sun
 * @LastEditTime: 2019-07-01 22:12:28
 -->
<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>splice数组的操作方法</title>
		<style>
			img {
				width: 400px;
				height: 400px;
			}
		</style>
		<script>
			window.onload = function() {
				let arr = [12, 15, 22, 1, 2, 3, 4, 5, 6]
				let brr = ["a", "b", "d"]
				//splice(起点,长度) 删除元素
				//arr.splice(2,3)

				//splice(起点,0,新增元素) 新增元素
				// arr.splice(2,0,'a','b','c')

				//splice(起点,删除替换,新增元素) 替换元素
				// arr.splice(2,3,'a','b','c')

				// let c=arr.concat(brr) es5 数组合并

				//let c=[...arr,...brr] //es6 数组合并

				// console.log(c.join("--"))

				// c.charAt(0) 截取字符串

				//  c.split(" ")  切割成数组 

				function sortNumber(a, b) { //数组的排序
					return a - b
				}
				let s = arr.sort(sortNumber)
				console.log(s)

			}
		</script>
	</head>

	<body>
		<img src="img/定时器1秒.jpg" />


	</body>

</html>
